<?php

namespace Database\Factories;

use App\Models\Correction;
use App\Models\ESCluster;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Analysis>
 */
class AnalysisFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        $result = "1#电池簇SOC最大误差值：5%，2#电池簇SOC最大误差值：5%，3#电池簇SOC最大误差值：5%";
        return [
            'dev_id' => $this->faker->randomElement(ESCluster::all()->pluck('id')),
            'dev_type' => 'App\Models\ESCluster', 
            'type' => $this->faker->randomElement(['SOC校正', 'SOH校正']),
            'result' => $result,
            'user_name' => $this->faker->unique()->name(),
            'user_id' => $this->faker->randomElement(User::all()->pluck('id')),
            'begin_at' => $this->faker->dateTimeBetween($startDate = '-2 days', '-1 days')->format('Y-m-d'),
            'end_at' => $this->faker->dateTimeBetween($startDate = '-1 days', $endDate = 'now')->format('Y-m-d'),
            'remarks' => '备注', 
            'correction_id' => $this->faker->randomElement(Correction::all()->pluck('id')),
        ];
    }
}
